<?php
/**
 * User.php		
 *
 * @package		
 * @Copyright	(c) All rights reserved
 * @Author		skyCrack <skyCrack@126.com>
 * @Version		$Id$
 */

class User
{
	public $userID		=	0;
	public $roleKey		=	'Guest';
	public $userName	=	'Guest';
	
	private $_decision	=	null;

	private function __construct() {
	}
	
	public static function getInstance() {
		static $instance	=	null;

		if ( $instance === null ) {
			$instance	=	new self();
		}
		
		return $instance;
	}
	
	public function hasPms($act) {
		if ( is_null($this->_decision)  ) {
			throw new Exception("auth decision is null");
		}
		
		if ( $this->_decision->decide($act) > 0 ) {
			return true;
		} else {
			return false;
		}
	}
	
	public function setDecision($decision) {
		$this->_decision = $decision;
	}

	public function __clone() {
		$this->userID		=	0;
		$this->roleKey		=	'Guest';
		$this->userName		=	'Guest';
		
		$this->_decision	=	null;
	}
}
?>